<?php

namespace app\index\validate;

use think\Validate;

/**
 * goods验证器
 */
class Goods extends Validate
{

    protected $rule = [
        'area'
            => 'require|in:1,2',
        'type'
            => 'require|in:1,2',
        'bargain'
            => 'require|in:0,1,2',
        'title|货物名称'
            => 'require|min:2|max:36',
        'price|标价'
            => 'require|max:4|between:0,10000|number',
        // TODO: 需补全分类验证
        'cate_id'
            => 'require|number',
        'deadline|上架期限'
            => 'require|between:3,180|number',
    ];

    protected $message = [
        'title.max'         => '名字不宜过长，12个汉字内适宜',
        'price.between'     => '别搞笑',
        'price.max'         => '不接受万元以上物品',
        'price.number'      => '标价只接受整数',
        'deadline.between'  => '上架期限只允许3~180天',
    ];

}
